import React, {useEffect, useState} from 'react'
import BatchUpload from '@/components/BatchUpload'
import {getData, getRentFree, postRentFree} from '@/service/order/index'

function FreeRent(props: any) {
	const {info, sunchange, getOrderList} = props
	const [batchFreeRent, setBatchFreeRent] = useState(false) // 批量免租
	useEffect(() => {
		setBatchFreeRent(info)
	}, [info])
	const childCange = (value: any) => {
		if (sunchange) {
			sunchange(value)
		}
	}
	const column = [
		{
			title: '订单编号',
			dataIndex: 'orderCarNo',
			align: 'center',
			key: 'orderCarNo',
			width: 200,
		},
		{
			title: '司机名称',
			dataIndex: 'driverName',
			align: 'center',
			key: 'driverName',
			width: 100,
		},
		{
			title: '车牌号',
			dataIndex: 'plateNo',
			align: 'center',
			key: 'plateNo',
			width: 100,
		},
		{
			title: '免租起始日',
			dataIndex: 'startTime',
			align: 'center',
			key: 'startTime',
			width: 100,
		},
		{
			title: '免租结束日',
			dataIndex: 'finishTime',
			align: 'center',
			key: 'finishTime',
			width: 100,
		},
		{
			title: '免租比例',
			dataIndex: 'ratio',
			align: 'center',
			key: 'ratio',
			width: 100,
		},
		// {
		//   title: '免租费用项',
		//   dataIndex: 'feeItemName',
		//   align: 'center',
		//   key:'feeItemName',
		//   width:100,
		// },
		{
			title: '状态',
			dataIndex: 'resultMsg',
			align: 'center',
			key: 'resultMsg',
			width: 200,
			fixed: 'right',
		},
	]
	return (
		<BatchUpload
			isModalOpen={batchFreeRent}
			setIsModalOpen={setBatchFreeRent}
			importData={getRentFree} // 导入接口
			onTableList={getData} // 获取列表数据-失败
			getListData={getOrderList} // 获取列表数据-成功
			columns={column}
			sourceId={36}
			templateType="批量申请免租"
			uploadFileUrl={postRentFree} // 文件上传接口
			title="申请免租"
			width={800}
			childCange={childCange}
		/>
	)
}

export default FreeRent
